/***************************************************************************
 *   Copyright (C) 2007 by Luca Bellonda                                   *
 *   lbell @ tsc4.com                                                      *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

package lb.prove;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class RssItem {

	public String title;
	public String body;
	public String guid;
	public String url;
	public Date date = new Date();
	public Date getDate()
	{
		return date;
	}
	public String pubDate;
	public boolean read;
	public boolean isDate=false;

	static final String [] dateFormats = new String [] {
		"EEE, dd MMM yyyy HH:mm:ss Z",
		"EEE dd MMM yyyy HH:mm:ss Z",			
		"EEE, dd MMM yyyy HH:mm:ss zzz",
		"EEEE, dd MMM yyyy HH:mm:ss zzz",
		"EEE MM d HH:mm:ss yyyy",
		"EEE, dd MMM yyyy HH:mm:ss z",
		"EEE, dd MMM yy HH:mm:ss z",
		"EEE dd MMM yyyy HH:mm:ss z",
		"EEE dd MMM yy HH:mm:ss z",
		"dd MMM yyyy HH:mm:ss z",
		"dd MMM yy HH:mm:ss z"
	};

	public void setPubDate( String theDate )
	{
		pubDate = theDate;
		SimpleDateFormat dateFormat = null;
		date = null ;
		for( String fmt : dateFormats )
		{
			try
			{
				dateFormat = new SimpleDateFormat(fmt,new Locale("en"));
				date = dateFormat.parse(theDate);
				break;
			}catch(Exception ex)
			{
			}
		}
		if(null==date)
			date = new Date();
	}
}
